package com.homson.coreservice.serviceview.controller;

import com.homson.coreservice.serviceapi.action.AccountActionApi;
import com.homson.coreservice.serviceapi.action.TransactionActionApi;
import com.homson.coreservice.serviceapi.action.UserActionApi;
import com.homson.coreservice.servicecommon.request.AccountCreateRequest;
import com.homson.coreservice.servicecommon.request.AddTransactionRequest;
import com.homson.coreservice.servicecommon.request.RequestParameter;
import com.homson.coreservice.servicecommon.co.UserCreateCO;
import com.homson.coreservice.servicecommon.response.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/action")
public class ActionController {
    
    @Autowired
    private UserActionApi userActionApi;
    
    @Autowired
    private TransactionActionApi transactionActionApi;
    
    @Autowired
    private AccountActionApi accountActionApi;
    
    @PostMapping("/user/register")
    public BaseResponse registerOrUpdateUser(@RequestBody RequestParameter<UserCreateCO> request){
        return userActionApi.registerOrUpdateUser(request);
    }
    
    @PostMapping("/transaction/add")
    public BaseResponse addTransaction(@RequestBody RequestParameter<AddTransactionRequest> request){
        return transactionActionApi.addTransaction(request);
    }
    
    @PostMapping("/account/create")
    public BaseResponse createAccount(@RequestBody RequestParameter<AccountCreateRequest> request){
        return accountActionApi.createAccount(request);
    }
    
}
